package com.example.springboot.common;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Data
@Component
@Configuration
@ConfigurationProperties (prefix = "minio")
public class MinioConfig {
    // Minio服务器地址
    private String url;
    // Minio服务器用户名
    private String accessKey;
    // Minio服务器密码
    private String secretKey;
    // 存储桶名称
    private String bucketName;

    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(url)
                .credentials(accessKey, secretKey)
                .build();
    }

}
